package com.AJava1710D.IO;

import java.io.*;
import java.net.Socket;

/**
 * 作者: LCG
 * 日期: 2020/7/1 09:51
 * 描述:
 */
public class IORunnerClient implements Runnable{
    @Override
    public void run() {

        try{
            Socket socket=new Socket("192.168.137.1",9998);

            OutputStream outputStream = socket.getOutputStream();

            PrintWriter printWriter=new PrintWriter(outputStream);

            printWriter.println(Thread.currentThread().getName()+"====client===sent to server===");

            printWriter.flush();

            InputStream inputStream = socket.getInputStream();

            InputStreamReader inputStreamReader=new InputStreamReader(inputStream);

            BufferedReader bufferedReader=new BufferedReader(inputStreamReader);

            String readLine = bufferedReader.readLine();

            System.out.println("====client===接收Server Data=》"+readLine);


            printWriter.close();
            outputStream.close();
            bufferedReader.close();
            inputStreamReader.close();
            inputStream.close();
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
